/**

 ║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║
 ║║  ______           _                                                          _                _      ║║
 ║║ |  ____|         | |                               /\                       | |              | |     ║║
 ║║ | |__     _   _  | |_   _   _   _ __    ___       /  \     _ __    _ __     | |        __ _  | |__   ║║
 ║║ |  __|   | | | | | __| | | | | | '__|  / _ \     / /\ \   | '_ \  | '_ \    | |       / _` | | '_ \  ║║
 ║║ | |      | |_| | | |_  | |_| | | |    |  __/    / ____ \  | |_) | | |_) |   | |____  | (_| | | |_) | ║║
 ║║ |_|       \__,_|  \__|  \__,_| |_|     \___|   /_/    \_\ | .__/  | .__/    |______|  \__,_| |_.__/  ║║
 ║║                                                           | |     | |                                ║║
 ║║                                                           |_|     |_|                                ║║
 ║║                                                                                                      ║║
 ║║           ******************************************************************************             ║║
 ║║                                                                                                      ║║
 ║║                 ___                 _      _     ____  _                               _   _         ║║
 ║║                |   \   __ _  __ __ (_)  __| |   |_  / (_)  _ __    _ __    ___   _ _  | | (_)        ║║
 ║║                | |) | / _` | \ V / | | / _` |    / /  | | | '  \  | '  \  / -_) | '_| | | | |        ║║
 ║║                |___/  \__,_|  \_/  |_| \__,_|   /___| |_| |_|_|_| |_|_|_| \___| |_|   |_| |_|        ║║                                
 ║║                ______________________________________________________________________________        ║║
 ║║                                                                                                      ║║
 ║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║
 

 */


package Cards;

import java.util.ArrayList;


import java.util.Collections;


public class dealOutCards {
	static ArrayList<Card> restCards = new ArrayList<Card>();



	public static void dealOutCards(ArrayList<Card> shuffleCards,boolean twoPlayers) {
			ArrayList<Card> player1Cards = new ArrayList<Card>();
			ArrayList<Card> player2Cards = new ArrayList<Card>();
			ArrayList<Card> player3Cards = new ArrayList<Card>();
			int numberOfHandCards = 14;
			restCards = shuffleCards;
		
		
		if (twoPlayers){
			for (int i = 0; i < numberOfHandCards ; i++){
				
				 player1Cards.add(dealCards())  ;
				 player2Cards.add(dealCards()) ;
				
			}
			
		} 
		else {
			for (int i = 0; i < numberOfHandCards ; i++){
				
				 player1Cards.add(dealCards()) ;
				 player2Cards.add(dealCards());
				 player3Cards.add(dealCards()) ;
			}	
			
			
		}
		
		
		// Sorting By Number
		Collections.sort(player1Cards, Card.cardNumberComparator);
		
		// Sorting By Color then by Number
		Collections.sort(player2Cards, Card.cardNameComparator);
		
		
		
		/** CONTROL */
		System.out.println("Player1: ");
		for (Card d: player1Cards){
			System.out.println(d.getCardNumber()  + " " + d.getCardName());
		}
		System.out.println("Player2: ");
		for (Card d: player2Cards){
			System.out.println(d.getCardName() );
		}
		
		
		
		
		
	}



	private static Card dealCards() {
		Card Card = restCards.get(1);
		 restCards.remove(1);
		
		
		return Card;
	}



}
